package my.springframework.bean.factory.support;

import my.springframework.bean.BeanException;
import my.springframework.bean.factory.config.BeanDefinition;

/**
 * @author sk
 * @description
 * @since 2021-11-23
 **/
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{

    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) throws BeanException {
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeanException("Instantiation of bean failed", e);
        }

        addSingleton(beanName, bean);
        return bean;
    }
}
